package coop.main.service;

import coop.main.domain.Detalle;
import coop.main.repository.DetalleRepository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class DetalleServiceImpl implements DetalleService {

	@Autowired
    DetalleRepository detalleRepository;

	public long countAllDetalles() {
        return detalleRepository.count();
    }

	public void deleteDetalle(Detalle detalle) {
        detalleRepository.delete(detalle);
    }

	public Detalle findDetalle(Long id) {
        return detalleRepository.findOne(id);
    }

	public List<Detalle> findAllDetalles() {
        return detalleRepository.findAll();
    }

	public List<Detalle> findDetalleEntries(int firstResult, int maxResults) {
        return detalleRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveDetalle(Detalle detalle) {
        detalleRepository.save(detalle);
    }

	public Detalle updateDetalle(Detalle detalle) {
        return detalleRepository.save(detalle);
    }
}
